{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Package loaded\n"
     ]
    }
   ],
   "source": [
    "\"\"\"\n",
    "Linear Regression\n",
    "author hadxu(hadxu123@gmail.com)\n",
    "\"\"\"\n",
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "print 'Package loaded'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x7fa3a3b49790>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAEACAYAAABWLgY0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt4lPWZ//H3PRwlEEDOCRDiuB4raq0HvNCGX4unXQS2\nIGrSmrpbbW2x9ZK26M8xibM90GIPy697VXeRsAvVtdZ6aqnGYqyt0npoq1WW1TAETQQVOcYDQu7f\nHxlCEmYmk8wkk5l8XteVi2eefOf53g9J7jz5Hs3dERGR3BTIdAAiItJzlORFRHKYkryISA5TkhcR\nyWFK8iIiOUxJXkQkh6Wc5M1stJk9ZmabzOxRMxsZo8xUM3vezF4ws5fM7NpU6xURkc5ZquPkzWwZ\nsMPdv2dm3wRGu/vSDmUGRuv6yMyGAS8DM9x9W0qVi4hIQulorpkLrI4erwbmdSzg7gfc/aPoy6MA\nS0O9IiLSiXQk+fHuvh0g+mQ+PlYhM5tsZn8F6oFleooXEel5A5MpZGY1wIS2pwAHbolRPGb7j7u/\nAZxqZhOBB83sPnd/u4vxiohIFySV5N19drzPmdl2M5vg7tujCfytTq61zcz+BpwH3B/jelpMR0Sk\ni9w9Z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vhX7HuiE0RLgDFmthWoAAYD7u53\nuvuvzewSM3sNaAK6PYFUk6FERHKYmmtERHKYkryISA5TkhcRyWFK8iIiOUxJXkQkhynJi4jkMCV5\nEZEcpiQvIpLD/j/XIp5olrgDxQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7fa3a37c7850>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Generate training data\n",
    "np.random.seed(1)\n",
    "def f(x,a,b):\n",
    "    n = train_X.size\n",
    "    vals = np.zeros((1,n))\n",
    "    for i in range(0,n):\n",
    "        ax = np.multiply(a,x.item(i))\n",
    "        val = np.add(ax,b)\n",
    "        vals[0,i] = val\n",
    "    return vals\n",
    "Wref = 0.7\n",
    "bref  = -1\n",
    "n = 20\n",
    "noise_var =0.001\n",
    "train_X = np.random.random((1,n))\n",
    "ref_Y = f(train_X,Wref,bref)\n",
    "train_Y = ref_Y + np.sqrt(noise_var)*np.random.randn(1,n)\n",
    "\n",
    "plt.figure(1)\n",
    "plt.plot(train_X[0,:],ref_Y[0,:],'ro',label='Origin data')\n",
    "plt.plot(train_X[0,:],train_Y[0,:],'bo',label='Train data')\n",
    "plt.axis('equal')\n",
    "plt.legend(loc='lower right')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#Prepare for Linear Regression\n",
    "\n",
    "#paremeters\n",
    "training_epochs = 2000\n",
    "display_step = 50\n",
    "\n",
    "#set Tensorflow Graph\n",
    "X = tf.placeholder(tf.float32,name='input')\n",
    "Y = tf.placeholder(tf.float32,name='output')\n",
    "W = tf.Variable(np.random.random(),name='weight')\n",
    "b = tf.Variable(np.random.random(),name='bias')\n",
    "activation = tf.add(tf.mul(W,X),b)\n",
    "\n",
    "learning_rate = 0.01\n",
    "cost = tf.reduce_mean(tf.pow(activation-Y,2))\n",
    "optimizer = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)\n",
    "\n",
    "\"\"\"\n",
    " tf.reduce_sum()\n",
    " tf.reduce_mean()\n",
    " _____\n",
    "\n",
    " tf.pow(Yhat, Y, 2)\n",
    " tf.nn.softmax_cross_entropy_with_logits(Yhat, Y)\n",
    " _____\n",
    "\n",
    " tf.train.GradientDescentOptimizer(0.05).minimize(cost)\n",
    " tf.train.RMSPropOptimizer(0.001, 0.9).minimize(cost)\n",
    "\"\"\"\n",
    "init = tf.initialize_all_variables()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('Epoch:', '0001', 'cost=', '0.92229')\n",
      "('Epoch:', '0001', 'cost=', '0.87884')\n",
      "('Epoch:', '0001', 'cost=', '0.84101')\n",
      "('Epoch:', '0001', 'cost=', '0.80279')\n",
      "('Epoch:', '0001', 'cost=', '0.76779')\n",
      "('Epoch:', '0001', 'cost=', '0.73502')\n",
      "('Epoch:', '0001', 'cost=', '0.70153')\n",
      "('Epoch:', '0001', 'cost=', '0.67185')\n",
      "('Epoch:', '0001', 'cost=', '0.64320')\n",
      "('Epoch:', '0001', 'cost=', '0.61554')\n",
      "('Epoch:', '0001', 'cost=', '0.58945')\n",
      "('Epoch:', '0001', 'cost=', '0.56334')\n",
      "('Epoch:', '0001', 'cost=', '0.53825')\n",
      "('Epoch:', '0001', 'cost=', '0.51520')\n",
      "('Epoch:', '0001', 'cost=', '0.49187')\n",
      "('Epoch:', '0001', 'cost=', '0.47189')\n",
      "('Epoch:', '0001', 'cost=', '0.45072')\n",
      "('Epoch:', '0001', 'cost=', '0.43133')\n",
      "('Epoch:', '0001', 'cost=', '0.41130')\n",
      "('Epoch:', '0001', 'cost=', '0.39216')\n",
      "('Epoch:', '0051', 'cost=', '0.00264')\n",
      "('Epoch:', '0051', 'cost=', '0.00264')\n",
      "('Epoch:', '0051', 'cost=', '0.00262')\n",
      "('Epoch:', '0051', 'cost=', '0.00262')\n",
      "('Epoch:', '0051', 'cost=', '0.00262')\n",
      "('Epoch:', '0051', 'cost=', '0.00262')\n",
      "('Epoch:', '0051', 'cost=', '0.00262')\n",
      "('Epoch:', '0051', 'cost=', '0.00262')\n",
      "('Epoch:', '0051', 'cost=', '0.00261')\n",
      "('Epoch:', '0051', 'cost=', '0.00261')\n",
      "('Epoch:', '0051', 'cost=', '0.00261')\n",
      "('Epoch:', '0051', 'cost=', '0.00260')\n",
      "('Epoch:', '0051', 'cost=', '0.00260')\n",
      "('Epoch:', '0051', 'cost=', '0.00259')\n",
      "('Epoch:', '0051', 'cost=', '0.00258')\n",
      "('Epoch:', '0051', 'cost=', '0.00257')\n",
      "('Epoch:', '0051', 'cost=', '0.00257')\n",
      "('Epoch:', '0051', 'cost=', '0.00257')\n",
      "('Epoch:', '0051', 'cost=', '0.00256')\n",
      "('Epoch:', '0051', 'cost=', '0.00256')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00083')\n",
      "('Epoch:', '0101', 'cost=', '0.00082')\n",
      "('Epoch:', '0101', 'cost=', '0.00082')\n",
      "('Epoch:', '0101', 'cost=', '0.00082')\n",
      "('Epoch:', '0101', 'cost=', '0.00082')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0151', 'cost=', '0.00060')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0201', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00056')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00056')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00056')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0251', 'cost=', '0.00056')\n",
      "('Epoch:', '0251', 'cost=', '0.00056')\n",
      "('Epoch:', '0251', 'cost=', '0.00056')\n",
      "('Epoch:', '0251', 'cost=', '0.00057')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00057')\n",
      "('Epoch:', '0301', 'cost=', '0.00057')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00057')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00057')\n",
      "('Epoch:', '0301', 'cost=', '0.00057')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0301', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00057')\n",
      "('Epoch:', '0351', 'cost=', '0.00057')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00057')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00057')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0351', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00057')\n",
      "('Epoch:', '0401', 'cost=', '0.00057')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00057')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00057')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0401', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00057')\n",
      "('Epoch:', '0451', 'cost=', '0.00057')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00057')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00057')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0451', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00057')\n",
      "('Epoch:', '0501', 'cost=', '0.00057')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00057')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00057')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0501', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00057')\n",
      "('Epoch:', '0551', 'cost=', '0.00057')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00057')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00057')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0551', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00057')\n",
      "('Epoch:', '0601', 'cost=', '0.00057')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00057')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00057')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0601', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00057')\n",
      "('Epoch:', '0651', 'cost=', '0.00057')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00057')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00057')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0651', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00057')\n",
      "('Epoch:', '0701', 'cost=', '0.00057')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00057')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00057')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0701', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00057')\n",
      "('Epoch:', '0751', 'cost=', '0.00057')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00057')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00057')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0751', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00057')\n",
      "('Epoch:', '0801', 'cost=', '0.00057')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00057')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00057')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0801', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00057')\n",
      "('Epoch:', '0851', 'cost=', '0.00057')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00057')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00057')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0851', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00057')\n",
      "('Epoch:', '0901', 'cost=', '0.00057')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00057')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00057')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0901', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00057')\n",
      "('Epoch:', '0951', 'cost=', '0.00057')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00057')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00057')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '0951', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00057')\n",
      "('Epoch:', '1001', 'cost=', '0.00057')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00057')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00057')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1001', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00057')\n",
      "('Epoch:', '1051', 'cost=', '0.00057')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00057')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00057')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1051', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00057')\n",
      "('Epoch:', '1101', 'cost=', '0.00057')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00057')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00057')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1101', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00057')\n",
      "('Epoch:', '1151', 'cost=', '0.00057')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00057')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00057')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1151', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00057')\n",
      "('Epoch:', '1201', 'cost=', '0.00057')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00057')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00057')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1201', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00057')\n",
      "('Epoch:', '1251', 'cost=', '0.00057')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00057')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00057')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1251', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00057')\n",
      "('Epoch:', '1301', 'cost=', '0.00057')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00057')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00057')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1301', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00057')\n",
      "('Epoch:', '1351', 'cost=', '0.00057')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00057')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00057')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1351', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00057')\n",
      "('Epoch:', '1401', 'cost=', '0.00057')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00057')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00057')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1401', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00057')\n",
      "('Epoch:', '1451', 'cost=', '0.00057')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00057')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00057')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1451', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00057')\n",
      "('Epoch:', '1501', 'cost=', '0.00057')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00057')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00057')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1501', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00057')\n",
      "('Epoch:', '1551', 'cost=', '0.00057')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00057')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00057')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1551', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00057')\n",
      "('Epoch:', '1601', 'cost=', '0.00057')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00057')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00057')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1601', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00057')\n",
      "('Epoch:', '1651', 'cost=', '0.00057')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00057')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00057')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1651', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00057')\n",
      "('Epoch:', '1701', 'cost=', '0.00057')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00057')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00057')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1701', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00057')\n",
      "('Epoch:', '1751', 'cost=', '0.00057')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00057')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00057')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1751', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00057')\n",
      "('Epoch:', '1801', 'cost=', '0.00057')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00057')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00057')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1801', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00057')\n",
      "('Epoch:', '1851', 'cost=', '0.00057')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00057')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00057')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1851', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00057')\n",
      "('Epoch:', '1901', 'cost=', '0.00057')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00057')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00057')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1901', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00057')\n",
      "('Epoch:', '1951', 'cost=', '0.00057')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00057')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00057')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "('Epoch:', '1951', 'cost=', '0.00056')\n",
      "0.690501\n",
      "-1.0007\n"
     ]
    }
   ],
   "source": [
    "#run\n",
    "sess = tf.Session()\n",
    "sess.run(init)\n",
    "for epoch in range(2000):\n",
    "    for (x,y) in zip(train_X[0,:],train_Y[0,:]):\n",
    "        sess.run(optimizer,feed_dict={X:x,Y:y})\n",
    "        if epoch % display_step==0:\n",
    "            costval = sess.run(cost,feed_dict={X:train_X,Y:train_Y})\n",
    "            print (\"Epoch:\", \"%04d\"%(epoch+1), \"cost=\", \"{:.5f}\".format(costval))\n",
    "            #Wtemp = sess.run(W)\n",
    "            #btemp = sess.run(b)\n",
    "            #print (\" Wtemp is\", \"{:.4f}\".format(Wtemp), \"btemp is\", \"{:.4f}\".format(btemp))\n",
    "            #print (\" Wref is\", \"{:.4f}\".format(Wref), \"bref is\", \"{:.4f}\".format(bref))\n",
    "Wopt = sess.run(W)\n",
    "bopt = sess.run(b)\n",
    "fopt = f(train_X,Wopt,bopt)\n",
    "print Wopt\n",
    "print bopt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "#plot Results\n",
    "plt.figure(2)\n",
    "plt.plot(train_X[0, :], ref_Y[0, :], 'ro', label='Original data')\n",
    "plt.plot(train_X[0, :], train_Y[0, :], 'bo', label='Training data')\n",
    "plt.plot(train_X[0, :], fopt[0, :], 'k-', label='Fitted Line')\n",
    "plt.axis('equal')\n",
    "plt.legend(loc='lower right')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "\"\"\"\n",
    "This example is very important!!!!!\n",
    "\"\"\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11+"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
